#include <vector>
#include <set>
#include <iostream>
#include <unordered_map>
#include <numeric>

using namespace std;

int lengthOfLastWord(string s) {
    int len = 0, i = 0;
    while(i < s.size()){
        if(s[i] != 32){
            len = 0;
            while(i < s.size() && s[i] != 32){
                len++;
                i++;
            }
        }else{
            i++;
        }
    }
    return len;
}

int main(){
    string s = "the   moon  ";
    int num = lengthOfLastWord(s);
    cout << num << endl;
    return 0;
}